You are an AI assistant that aids users in performing data analysis using Python and Pandas to find information.

There is the dataset: you have the datafastfoodcontains the following columns:['restaurant', 'item', 'calories', 'cal_fat', 'total_fat', 'sat_fat', 'trans_fat', 'cholesterol', 'sodium', 'total_carb', 'fiber', 'sugar', 'protein', 'vit_a', 'vit_c', 'calcium', 'salad'].
--- The description for each column this data is:
restaurant: Name of fast food restaurant (McDonalds, Chick Fil-A, Sonic...etc)
item: Menu item at the restaurant (Artisan Grilled Chicken Sandwich, Single Bacon Smokehouse Burger, and Big Mac...etc) 
calories: Energy content of the food item (measured in calories) 
cal_fat: Calories in the item come from fats (measured in calories)
total_fat: Total amount of fat in the item (measured in grams)
sat_fat: The amount of saturated fat in the item (measured in grams) 
trans_fat: Trans fat content of the item (measured in grams) 
cholesterol: Cholesterol content of the item (measured in milligrams)
sodium: Sodium content of the item (measured in milligrams)
total_carb: Total carbohydrates in the item (measured in grams)
fiber: Dietary fiber content of the item (measured in grams)
sugar: Total sugar content in the item (measured in grams)
protein: Total protein content in the item (measured in grams)
vit_A: Vitamin A content in the item (measured in a percentage of the recommended daily intake) 
vit_C: Vitamin C content in the item (measured in a percentage of the recommended daily intake) 
calcium: Calcium content in the item (measured in a percentage of the recommended daily intake) 
salad: Type of food item (main course, side dish, or dessert)
---
Considering contents from the dataset and result types from user, you only need to generate codes and notations. Please note DO NOT CHANGE FILE AND VARIABLE NAMES THAT I HAVE SET!
Conversation begins:
[USER (data scientist)]: Hey there! I've got this dataset of fast food items in a CSV file named "fastfood.csv". I'm trying to figure out which ones are healthy and which ones aren't based on some nutritional values. Can you help me out? 
 
[YOU (AI assistant)]: Of course! I'd be happy to help. Since we'll be using pandas to read the CSV file, do you already have it installed? 
 
[USER (data scientist)]: Yup, pandas is good to go! Please generate and display a dataframe to identify and separate healthy and unhealthy food items based on specific nutritional criteria (calories, total fat, sodium, sugar, and protein) from the 'fastfood.csv' dataset.

[YOU (AI assistant)]: Awesome! Let's start by loading the data from the CSV file :
'''
import pandas as pd   
import pickle

# Read the fastfood data
fastfood = pd.read_csv("fastfood.csv")

# Define the thresholds
max_calories = 500
max_total_fat = 20
max_sodium = 800
max_sugar = 15
min_protein = 10
 
# Create healthy and unhealthy dataframes
healthy_items = fastfood[(fastfood['calories'] <= max_calories) &
                         (fastfood['total_fat'] <= max_total_fat) &
                         (fastfood['sodium'] <= max_sodium) &
                         (fastfood['sugar'] <= max_sugar) &
                         (fastfood['protein'] >= min_protein)] 
 
unhealthy_items = fastfood[~fastfood.index.isin(healthy_items.index)]

print(unhealthy_items)

'''

[USER (data scientist)]: The max calorie count for a food item to be considered healthy should be no more than 500 calories. 
 
[YOU (AI assistant)]: Got it, 500 calories it is. How about the total fat? What's the max limit for that? 
 
[USER (data scientist)]: Keep it under 20 grams of fat. 
 
[YOU (AI assistant)]: Alright, under 20 grams of fat. What's the sodium limit for a healthy item? 
 
[USER (data scientist)]: No more than 800 milligrams of sodium. 
 
[YOU (AI assistant)]: Thanks! And what about sugar? What's the max limit for that? 
 
[USER (data scientist)]: 15 grams of sugar should be the limit. 
 
[YOU (AI assistant)]: Perfect, 15 grams of sugar. Lastly, what's the minimum protein requirement for a food item to be considered healthy? 
 
[USER (data scientist)]: At least 10 grams of protein. Please calculate and display the Comprehensive Modified NRF Index for each item in the DataFrame 'fastfood', including percentages of Recommended Daily Intake (RDI) for various nutrients.

[YOU (AI assistant)]: Thanks for all the info! Now let's filter the healthy and unhealthy food items based on these thresholds :
'''
 
import pandas as pd   
import pickle
   
# Assuming the dataset is loaded as a DataFrame named 'fastfood'   
   
# Recommended Daily Intake (RDI) values   
rdi_protein = 50   
rdi_fiber = 25   
rdi_vit_a = 5000   
rdi_vit_c = 60   
rdi_calcium = 1000   
rdi_sat_fat = 20   
rdi_trans_fat = 2   
rdi_sugar = 50   
rdi_sodium = 2400   
rdi_total_carb = 300   
   
# Calculate the percentage of RDI for each nutrient   
fastfood['protein_score'] = (fastfood['protein'] / rdi_protein) * 100   
fastfood['fiber_score'] = (fastfood['fiber'] / rdi_fiber) * 100   
fastfood['vit_a_score'] = (fastfood['vit_a'] / rdi_vit_a) * 100   
fastfood['vit_c_score'] = (fastfood['vit_c'] / rdi_vit_c) * 100   
fastfood['calcium_score'] = (fastfood['calcium'] / rdi_calcium) * 100   
fastfood['sat_fat_score'] = (fastfood['sat_fat'] / rdi_sat_fat) * 100   
fastfood['trans_fat_score'] = (fastfood['trans_fat'] / rdi_trans_fat) * 100   
fastfood['sugar_score'] = (fastfood['sugar'] / rdi_sugar) * 100   
fastfood['sodium_score'] = (fastfood['sodium'] / rdi_sodium) * 100   
fastfood['total_carb_score'] = (fastfood['total_carb'] / rdi_total_carb) * 100   
   
# Calculate the Comprehensive Modified NRF Index   
fastfood['comprehensive_modified_nrf_index'] = (fastfood['protein_score'] + fastfood['fiber_score'] + fastfood['vit_a_score'] + fastfood['vit_c_score'] + fastfood['calcium_score']) - (fastfood['sat_fat_score'] + fastfood['trans_fat_score'] + fastfood['sugar_score'] + fastfood['sodium_score'] + fastfood['total_carb_score']) 

print(fastfood)

'''

[USER (data scientist)]: Hey, I've got this dataset of fast food items, and I wanna sort them into vegetarian, vegan, and gluten-free categories. Can you help me out? 
 
[YOU (AI assistant)]: Absolutely! Let's start by listing some keywords for each category. For vegetarian, we can exclude items with chicken, beef, pork, bacon, fish, and shrimp. For vegan, we'll exclude all vegetarian keywords plus egg, cheese, milk, cream, and honey. And for gluten-free, we'll exclude items with bread, bun, roll, muffin, wrap, pizza, pasta, noodle, pancake, waffle, cookie, cake, pastry, sandwich, bagel, pretzel, and doughnut. Does that work for you? 
 
[USER (data scientist)]: Yeah, that's perfect. Show me the code for these keywords. Please generate and save lists for 'vegetarian_keywords', 'vegan_keywords', and 'gluten_keywords' from the 'fastfood.csv' dataset to identify ingredients related to dietary restrictions.

[YOU (AI assistant)]: You got it! Here's the code to define the keywords for each category :
'''
import pandas as pd   
import pickle
   
# Read the fastfood data
fastfood = pd.read_csv("fastfood.csv")
 
vegetarian_keywords = ['chicken', 'beef', 'pork', 'bacon', 'fish', 'shrimp', 'lobster', 'turkey', 'gyro', 'brisket', 'steak', 'ham', 'hot dog', 'corn dog', 'pastrami', 'meatball', 'rib', 'tuna']
vegan_keywords = vegetarian_keywords + ['cheese', 'buttermilk', 'honey', 'ranch', 'cheddar', 'asiago', 'parmesan', 'cream', 'milk', 'dressing', 'mayo', 'mayonnaise', 'butter', 'egg']
gluten_keywords = ['bread', 'bun', 'roll', 'muffin', 'wrap', 'pizza', 'pasta', 'noodle', 'pancake', 'waffle', 'cookie', 'cake', 'pastry', 'sandwich', 'bagel', 'pretzel', 'doughnut']

print(vegetarian_keywords)

print(vegan_keywords)

print(gluten_keywords)

'''

[USER (data scientist)]: Cool! Now, how about functions to check if an item belongs to a specific category? Please generate functions to classify items in the DataFrame 'fastfood' based on vegetarian, vegan, and gluten-free dietary preferences.

[YOU (AI assistant)]: Sure thing! We can create functions that check for the presence of those keywords in the item's name. Here are the functions for each category :
'''
import pandas as pd   
import pickle

# Read the fastfood data
fastfood = pd.read_csv("fastfood.csv")

def is_vegetarian(item):
    return not any(keyword.lower() in item.lower() for keyword in vegetarian_keywords)
 
def is_vegan(item):
    return not any(keyword.lower() in item.lower() for keyword in vegan_keywords)
 
def is_gluten_free(item):
    return not any(keyword.lower() in item.lower() for keyword in gluten_keywords)

'''

[USER (data scientist)]:Nice! So, how do I use these functions with my dataset? Please enrich the DataFrame 'fastfood' by categorizing menu items based on their dietary attributes—vegetarian, vegan, and gluten-free—and persist these categorizations for future reference.

My template of code snippet is:

---BEGIN CODE TEMPLATE--- 

import pandas as pd
import pickle

# Read the fastfood data 
fastfood = pd.read_csv("fastfood.csv")  

# YOUR SOLUTION BEGIN:
<code1>
[GENERATE YOUR CODE]
</code1>
# YOUR SOLUTION END: 

print(fastfood['vegetarian'])
pickle.dump(fastfood['vegetarian'],open("./pred_result/fastfood['vegetarian'].pkl","wb"))

print(fastfood['vegan'])
pickle.dump(fastfood['vegan'],open("./pred_result/fastfood['vegan'].pkl","wb"))

print(fastfood['gluten_free'])
pickle.dump(fastfood['gluten_free'],open("./pred_result/fastfood['gluten_free'].pkl","wb"))
 
Please note that you have to generate the WHOLE python code instead of code segments based on the code snippet using Pandas library 2.0.3 version and Matplotlib library 3.7.4 version. You must keep all comments in code snippet unchanged.

[YOU (AI assistant)]: Assuming your dataset is in a DataFrame called fastfood and the item names are in a column called 'item', you can apply these functions like this: 

